/**
 * @file BT.c
 * @brief bluetooth Interface
 *
 * @version Fixed
 * @author lbx
 * @date 2015-04-28
 */
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/err.h>
#include <fcntl.h>
#include <device.h>
#include "bt.h"

static int bt_fd = -1;

int bt_dev_init(void)
{
    bt_fd = open(CONFIG_BT_DEV, O_RDWR|O_NONBLOCK);
    return ioctl(bt_fd, IOCTL_BT_INIT, NULL);  
}

int bt_set_name(const char *name, uint32_t len)
{
    bt_name_t param;

    param.name = name;
    param.len = len;
    return ioctl(bt_fd, IOCTL_BT_SET_NAME, &param);
}

int bt_get_name(const char *name, uint32_t len)
{
    bt_name_t param;

    param.name= name;
    param.len = len;
    return ioctl(bt_fd, IOCTL_BT_GET_NAME, &param);
}

int bt_get_addr(uint8_t addr[6])
{
    return ioctl(bt_fd, IOCTL_BT_GET_ADDR, addr);
}

int bt_set_addr(uint8_t addr[6])
{
    return ioctl(bt_fd, IOCTL_BT_SET_ADDR, addr);
}

